using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class VW_Tuny_EventH {
		#region Fields
		private int id;
		private string eventTitle;
		private string picUrl;
		private DateTime startDate = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
		private DateTime endDate = System.Data.SqlTypes.SqlDateTime.MinValue.Value;
		private string startCityName;
		private int attendCount;
		private int attentionCount;
		private double totalCost;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the VW_Tuny_EventH class.
		/// </summary>
		public VW_Tuny_EventH() {
		}
		
		/// <summary>
		/// Initializes a new instance of the VW_Tuny_EventH class.
		/// </summary>
		public VW_Tuny_EventH(string eventTitle, string picUrl, DateTime startDate, DateTime endDate, string startCityName, int attendCount, int attentionCount, double totalCost) {
			this.eventTitle = eventTitle;
			this.picUrl = picUrl;
			this.startDate = startDate;
			this.endDate = endDate;
			this.startCityName = startCityName;
			this.attendCount = attendCount;
			this.attentionCount = attentionCount;
			this.totalCost = totalCost;
		}
		
		/// <summary>
		/// Initializes a new instance of the VW_Tuny_EventH class.
		/// </summary>
		public VW_Tuny_EventH(int id, string eventTitle, string picUrl, DateTime startDate, DateTime endDate, string startCityName, int attendCount, int attentionCount, double totalCost) {
			this.id = id;
			this.eventTitle = eventTitle;
			this.picUrl = picUrl;
			this.startDate = startDate;
			this.endDate = endDate;
			this.startCityName = startCityName;
			this.attendCount = attendCount;
			this.attentionCount = attentionCount;
			this.totalCost = totalCost;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the Id value.
		/// </summary>
		public int Id {
			get { return id; }
			set { id = value; }
		}
		
		/// <summary>
		/// Gets or sets the EventTitle value.
		/// </summary>
		public string EventTitle {
			get { return eventTitle; }
			set { eventTitle = value; }
		}
		
		/// <summary>
		/// Gets or sets the PicUrl value.
		/// </summary>
		public string PicUrl {
			get { return picUrl; }
			set { picUrl = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartDate value.
		/// </summary>
		public DateTime StartDate {
			get { return startDate; }
			set { startDate = value; }
		}
		
		/// <summary>
		/// Gets or sets the EndDate value.
		/// </summary>
		public DateTime EndDate {
			get { return endDate; }
			set { endDate = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartCityName value.
		/// </summary>
		public string StartCityName {
			get { return startCityName; }
			set { startCityName = value; }
		}
		
		/// <summary>
		/// Gets or sets the AttendCount value.
		/// </summary>
		public int AttendCount {
			get { return attendCount; }
			set { attendCount = value; }
		}
		
		/// <summary>
		/// Gets or sets the AttentionCount value.
		/// </summary>
		public int AttentionCount {
			get { return attentionCount; }
			set { attentionCount = value; }
		}
		
		/// <summary>
		/// Gets or sets the TotalCost value.
		/// </summary>
		public double TotalCost {
			get { return totalCost; }
			set { totalCost = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the VW_Tuny_EventH table.
		/// </summary>
		public void Insert() {
			id = Convert.ToInt32(SqlClientUtility.ExecuteScalar("VW_Tuny_EventHInsert", eventTitle, picUrl, startDate, endDate, startCityName, attendCount, attentionCount, totalCost));
		}
		
		/// <summary>
		/// Selects all records from the VW_Tuny_EventH table.
		/// </summary>
		public static List<VW_Tuny_EventH> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("VW_Tuny_EventHSelectAll")) {
				List<VW_Tuny_EventH> vW_Tuny_EventHList = new List<VW_Tuny_EventH>();
				while (dataReader.Read()) {
					VW_Tuny_EventH vW_Tuny_EventH = MakeVW_Tuny_EventH(dataReader);
					vW_Tuny_EventHList.Add(vW_Tuny_EventH);
				}
				return vW_Tuny_EventHList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the VW_Tuny_EventH class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static VW_Tuny_EventH MakeVW_Tuny_EventH(SqlDataReader dataReader) {
			VW_Tuny_EventH vW_Tuny_EventH = new VW_Tuny_EventH();
			
			if (dataReader.IsDBNull(0) == false) {
				vW_Tuny_EventH.Id = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				vW_Tuny_EventH.EventTitle = dataReader.GetString(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				vW_Tuny_EventH.PicUrl = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				vW_Tuny_EventH.StartDate = dataReader.GetDateTime(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				vW_Tuny_EventH.EndDate = dataReader.GetDateTime(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				vW_Tuny_EventH.StartCityName = dataReader.GetString(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				vW_Tuny_EventH.AttendCount = dataReader.GetInt32(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				vW_Tuny_EventH.AttentionCount = dataReader.GetInt32(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				vW_Tuny_EventH.TotalCost = dataReader.GetDouble(8);
			}

			return vW_Tuny_EventH;
		}
		#endregion
	}
}
